<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>常用全局api-set的用法</title>
</head>
<body>
    <div id="app">
        <div>
            我想用自定义指令变红
            <ul>
                <li v-for="item in items">{{item.name}}</li>
            </ul>
            <button @click="change">change</button>
        </div>
    </div>
    <!-- vue2 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>

    <script>
        var app = new Vue({
            el:"#app",
            data:{
                items:[{name:0},{name:1}]
            },
            methods:{
                change(){
                    // Vue.set(this.items,0,{name:3});
                    this.$set(this.items,0,{name:3});
                }
            }
        })
    </script>
</body>
</html>